<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>simLoadModule</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../../index.html" TARGET="_top"><img src="../images/homeImg.png"></a></p>

<h1>Regular API function</h1>
<h3 class=subsectionBar><a name="simLoadModule" id="simLoadModule"></a>simLoadModule / sim.loadModule </h3>
<table class=apiTable>
<tr class=apiTableTr> 
<td class=apiTableLeftDescr>
Description 
</td> 
<td class=apiTableRightDescr>Loads a CoppeliaSim <a href="../plugins.htm">plugin</a>. This should usually be done in the <a href="../mainClientApplication.htm">main client application</a>, just after <a href="simRunSimulator.htm">simRunSimulator</a> was called. Alternatively, you can also dynamically load/unload a plugin, but depending on the plugin function, this might not work/lead to a crash. In case the dynamically loaded plugin registers custom Lua functions, those functions cannot be used in scripts that were already initialized (except for the script that called <em>sim.loadModule</em>). Normally, all plugins of type <em>simExtXXX.dll</em> (or <em>libsimExtXXX.so</em> or<em> libsimExtXXX.dylib</em>) in the CoppeliaSim directory are loaded at application start. Plugins that are meant to be dynamically loaded should use a different name, or a different directory. See also <a href="simSendModuleMessage.htm">simSendModuleMessage</a> and <a href="simUnloadModule.htm">sim.unloadModule</a>.<br></td>
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCSyn>
C synopsis
</td> 
<td class=apiTableRightCSyn>simInt simLoadModule(const simChar* filenameAndPath,const simChar* pluginName)<br></td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCParam>C parameters</td> 
<td class=apiTableRightCParam>
<div><span class="apiTableRightCSyn"><strong>filenameAndPath</strong></span>: file name and path of the plugin</div>
<div><span class="apiTableRightCSyn"><strong>pluginName</strong></span>: name of the plugin. If the file name is <em>simExtXXX.dll</em>, then the name should be <em>XXX</em></div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftCRet>
C return value
</td> 
<td class=apiTableRightCRet>
<div>handle of the plugin if value is 0 or positive. otherwise:</div>
<div class=tab>-3: plugin could not be loaded</div>
<div class=tab>-2: plugin is missing entry points</div>
<div class=tab>-1: plugin could not initialize</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLSyn>
Lua synopsis
</td> 
<td class=apiTableRightLSyn>int pluginHandle=sim.loadModule(string filenameAndPath,string pluginName)</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLParam>Lua parameters</td> 
<td class=apiTableRightLParam>
<div>Similar to the C-function counterpart</div>
</td> 
</tr> 
<tr class=apiTableTr> 
<td class=apiTableLeftLRet>
Lua return values
</td> 
<td class=apiTableRightLRet>
<div>Similar to the C-function counterpart</div>
</td> 
</tr> 
</table> 


<br>
</td>
</tr>
</table>
</div>
</body>
</html>
